package com.yes.yjj;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class AppAni {
    public static void main(String[] args) throws Exception{
        Class<?> AA = Class.forName("com.yes.yjj.Animal");
        Object o = AA.newInstance();
        Field name = AA.getDeclaredField("name");
        name.setAccessible(true);
        name.set(o,"猫");
        Method getName = AA.getMethod("getName");
        Object result1 = getName.invoke(o);
        System.out.println(result1);

        Field age = AA.getDeclaredField("age");
        age.setAccessible(true);
        age.set(o,6);
        Method getAge = AA.getMethod("getAge");
        Object result2 = getAge.invoke(o);
        System.out.println(result2);


    }
}
